BloodSplatter = class('BloodSplatter', Feature)

function BloodSplatter:initialize(x, y, rot)

	local offX = blood_splatter_img:getWidth()/2
	local offY = blood_splatter_img:getHeight()/2

	Feature.initialize(self, "blood_splatter", blood_splatter_img, x, y, rot,
		nil, nil, offX, offY)

end

function BloodSplatter:use()

	if player.mopping then
		--if features[self.y_index] then print("splatter features y good")end
		features[self.y_index][self.x_index] = nil		
		if not player.splatters_cleaned then player.splatters_cleaned = 1 
			else player.splatters_cleaned = player.splatters_cleaned + 1 end
		draw_text('splatter mopped')
		if BloodSplatter:is_gone() == true then m_splatter_callback() end

	end

end

function BloodSplatter:is_gone()

	for y = 1, map_h do
		if features[y] then
			for x = 1, map_w do
				if features[y][x] then
					if features[y][x].name == "blood_splatter" then
						return false
					end
				end
			end
		end
	end

	return true

end

function BloodSplatter:place_random( amount, layout, floor_type)

	local _floor = {}

	for y = 1, #layout do
		if layout[y] then
			for x = 1, #layout[y] do
				if layout[y][x] then
					if layout[y][x] == floor_type then
						local id = #_floor+1
						_floor[id] = {}
						_floor[id].x = x
						_floor[id].y = y
					end
				end
			end
		end
	end

	for i = 1, amount do

		local total_floor = #_floor
		local r = RNG:random(total_floor)
		local skip = false
		if features[_floor[r].y] then
			if features[_floor[r].y][_floor[r].x] then
				skip = true
			end
		end
		if not skip then 
			local rot = random_rotation()

			BloodSplatter:new(_floor[r].x, _floor[r].y, rot) 
		end

	end


end
